package com.rsg.pmx.bean;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.AjaxBehaviorEvent;



@SessionScoped
@ManagedBean(name="projectBean")
public class ProjectBean implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8814085841867442258L;
	private String name;
	private File uploadedFile;
	private List<ProjectItemBean> projectItems = new ArrayList<ProjectItemBean>();

	public ProjectBean() {
		System.out.println("constructeur ProjectBean ");
		projectItems.add(new ProjectItemBean(""));
	}

	public List<ProjectItemBean> getProjectItems() {
		return projectItems;
	}

	public void setProjectItems(List<ProjectItemBean> projectItems) {
		this.projectItems = projectItems;
	}

	public Object getUploadedFile() {
		return uploadedFile;
	}

	public void newTaskItem(AjaxBehaviorEvent event) {
		ProjectItemBean item = new ProjectItemBean("");
		projectItems.add(item); //item.getTaskInputComponent().
		System.out.println("newTaskItem");
	}

//	public void fileUploadListener(FileUploadEvent event) {
//		UploadedFile item = event.getUploadedFile();
//		String text = null;
//		if (item != null) {
//			text = new String(item.getData());
//			System.out.println(text);
//		}
//
//	}
}
